package com.yue.pattern.singleton;

/**
 * 饿汉单例
 */
public class Lazy {

    //类加载顺序：先静态，后动态
    //先属性，后方法
    //先上 后下
    private Lazy() {
    }

    private static Lazy hungry = null;

    public static synchronized Lazy getInstance() {

        if (null == hungry) {
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            hungry = new Lazy();
        }
        return hungry;
    }
}
